unit CadastroProcesso;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UFomCadastro, StdCtrls, Buttons, ExtCtrls, DB, DBTables, Mask,
  DBCtrls, DBClient, Provider, Menus, ComCtrls, Grids, DBGrids;

type
  TFCadastroProcesso = class(TFormCadastro)
    Label14: TLabel;
    DBText1: TDBText;
    Label1: TLabel;
    DBENome: TDBEdit;
    QProcesso: TQuery;
    DSProcesso: TDataSource;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure FormCreate(Sender: TObject);
    procedure BtnIncluirClick(Sender: TObject);
    procedure BtnEditarClick(Sender: TObject);
    procedure BtnExcluirClick(Sender: TObject);
    procedure BtnSalvarClick(Sender: TObject);
    procedure BtnConsutaClick(Sender: TObject);
    procedure QCadastroBeforePost(DataSet: TDataSet);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FCadastroProcesso: TFCadastroProcesso;

implementation

uses UGeral, PesquisaProcesso;

{$R *.dfm}

procedure TFCadastroProcesso.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
 FCadastroProcesso:=nil;
  inherited;
end;

procedure TFCadastroProcesso.FormCreate(Sender: TObject);
begin
  QCadastro.SQL.Clear;
  QCadastro.SQL.Add('SELECT * FROM PROCESSO');
  inherited;
end;

procedure TFCadastroProcesso.BtnIncluirClick(Sender: TObject);
begin

  inherited;
  DBENome.SetFocus;

end;

procedure TFCadastroProcesso.BtnEditarClick(Sender: TObject);
begin

  if DsCadastro.DataSet.IsEmpty then
   begin
    ShowMessage('Tabela esta vazia !');
    exit;
   end;

  inherited;
  DBENome.SetFocus;

end;

procedure TFCadastroProcesso.BtnExcluirClick(Sender: TObject);
begin

  if DsCadastro.DataSet.IsEmpty then
   begin
    ShowMessage('Tabela esta vazia !');
    exit;
   end;

  if MessageDlg('Deseja realmente excluir este Tipo Documento ? ',mtWarning,mbOKCancel,0) = 2 then
   exit;

  inherited;

end;

procedure TFCadastroProcesso.BtnSalvarClick(Sender: TObject);
begin

  if DBENome.Text = '' then
  begin
   ShowMessage('Campo Nome tem que ser preenchido !');
   exit;
  end;

  inherited;

end;

procedure TFCadastroProcesso.BtnConsutaClick(Sender: TObject);
begin
  inherited;
 Application.CreateForm(TFPesquisaProcesso, FPesquisaProcesso);
 FPesquisaProcesso.Show;
 Self.Enabled:=False;

end;

procedure TFCadastroProcesso.QCadastroBeforePost(DataSet: TDataSet);
begin
  inherited;
  DataSet.FieldByName('USUARIO').AsString:=Usuario;
  DataSet.FieldByName('DATAMODIFICACAO').AsDateTime:=Date;
end;

end.
